import React from 'react';
import {
  View,
  TouchableOpacity
} from 'react-native';

import WebViewPage from '../common/WebViewPage';
import UserRequestAPPConfigAction from '../../actions/user/UserRequestAPPConfigAction';
export default class VipOpenCardWebViewPage extends WebViewPage {
  constructor(props) {
    super(props);
    this.state.configData = null;
  }

 componentWillUpdate(nextProps, nextState) {
    if(nextState.configSuccess)
    {
      nextState.configSuccess = false;
      nextState.source = {uri: nextState.configValue};
      this._customUrl = nextState.configValue;
      nextState.url = nextState.configValue;;
    }
  }
  _dealAfterEnterAnimation() {
    this._initUrl();
  }

  _initUrl() {
    if(this.props.pageData &&this.props.pageData.routeData.buttonData
       && this.props.pageData.routeData.buttonData.config_key){
      new UserRequestAPPConfigAction().call(this, {key:this.props.pageData.routeData.buttonData.config_key ,requestType:"config"});
    }
    else {
      this._setUrl(this.props.pageData.routeData.buttonData);
    }
  }

  _isRenderWebView(){
    return this.state.configData != null;
  }

  _getTitle() {
    return this.props.pageData.routeData.buttonData.name;
  }
}
